package org.example.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.entity.ClassAnswer;
import org.example.mapper.ClassAnswerMapper;
import org.example.service.ClassAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;

/**
 * @ClassName ClassAnswerServiceImpl
 * @Description TODO
 * @Author qiuye
 * @Date 2025年08月19日 0:37
 * @Version 1.0
 */
@Service
public class ClassAnswerServiceImpl implements ClassAnswerService {
    @Autowired
    private ClassAnswerMapper classAnswerMapper;

    @Override
    public List<ClassAnswer> getClassAnswerById(int questionId) {
        List<ClassAnswer> classAnswerById = classAnswerMapper.getClassAnswerById(questionId);
        return classAnswerById;
    }

    @Override
    public PageInfo<ClassAnswer> getClassAnswerHui(ClassAnswer classAnswer,int page,int size) {
        PageHelper.startPage(page,size);
        List<ClassAnswer> classAnswerById = classAnswerMapper.getClassAnswerById(classAnswer.getId());
        PageInfo<ClassAnswer> pageInfo = new PageInfo<>(classAnswerById);
        return pageInfo;
    }

    @Override
    public void addAnswer(ClassAnswer answer) {
        classAnswerMapper.insertAnswer(answer);
    }


}
